<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>完美电商</title>
    <!-- Bootstrap -->
    <link
            href="${pageContext.request.contextPath }/static/vendors/bootstrap/dist/css/bootstrap.min.css"
            rel="stylesheet">
    <!-- Font Awesome -->
    <link
            href="${pageContext.request.contextPath }/static/vendors/font-awesome/css/font-awesome.min.css"
            rel="stylesheet">
    <!-- NProgress -->
    <link
            href="${pageContext.request.contextPath }/static/vendors/nprogress/nprogress.css"
            rel="stylesheet">
    <!-- iCheck -->
    <link
            href="${pageContext.request.contextPath }/static/vendors/iCheck/skins/flat/green.css"
            rel="stylesheet">
    <!-- bootstrap-progressbar -->
    <link
            href="${pageContext.request.contextPath }/static/vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css"
            rel="stylesheet">
    <!-- JQVMap -->
    <link
            href="${pageContext.request.contextPath }/static/vendors/jqvmap/dist/jqvmap.min.css"
            rel="stylesheet"/>

    <!-- Custom Theme Style -->
    <link
            href="${pageContext.request.contextPath }/static/build/css/custom.min.css"
            rel="stylesheet">
    <!-- PNotify -->
    <link href="${pageContext.request.contextPath }/static/vendors/pnotify/dist/pnotify.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/static/vendors/pnotify/dist/pnotify.buttons.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/static/vendors/pnotify/dist/pnotify.nonblock.css" rel="stylesheet">
</head>

<body class="nav-md">
<div class="container body">
    <div class="main_container">
        <%@ include file="/WEB-INF/jsps/menu.jsp" %>
        <!-- top navigation -->
        <%@include file="/WEB-INF/jsps/top.jsp" %>
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="row">
                <div class="col-md-12 col-sm-12 col-xs-12">
                    <div class="x_panel">
                        <div class="x_title">
                            <h2>修改订单
                                <small>修改订单详情（只允许修改收货地址）</small>
                            </h2>
                            <div class="clearfix"></div>
                        </div>
                        <div class="x_content">
                            <form class="form-horizontal form-label-left" id="AddForm">
                                <input type="hidden" id="oid" name="oid" value="${orderProduct.oid}"/>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3">订单ID
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6">
                                        <input disabled value="${orderProduct.oid}"
                                               class="form-control col-md-7 col-xs-12">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3 col-xs-12">收货地址
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-5 col-sm-9 col-xs-12">
                                        <select id="addressid" name="addressid" class="form-control">

                                            <c:forEach items="${address}" var="address">
                                                <option value="${address.addressid}">${address.provinceid}${address.cityid}${address.areaid}${address.address}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3">商品数量
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6">
                                        <input type="number" id="productnum" name="productnum" disabled
                                               value="${orderProduct.productnum }" required="required"
                                               class="form-control col-md-7 col-xs-12">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3">订单状态
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6">
                                        <input type="number" id="ostate" name="ostate" disabled
                                               value="${orderProduct.ostate }" required="required"
                                               class="form-control col-md-7 col-xs-12">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3">折扣
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6">
                                        <input type="number" id="discount" name="discount" disabled
                                               value="${orderProduct.discount }" required="required"
                                               class="form-control col-md-7 col-xs-12">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3">邮费
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6">
                                        <input type="number" id="post" name="post" required="required" disabled
                                               value="${orderProduct.post }"
                                               class="form-control col-md-7 col-xs-12">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3">合计
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6">
                                        <input type="number" id="total" name="total" required="required" disabled
                                               value="${orderProduct.total }"
                                               class="form-control col-md-7 col-xs-12">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3">支付方式
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6" >
                                        <input type="text" id="paymethod" name="paymethod"
                                                required="required" value="" disabled
                                               class="form-control col-md-7 col-xs-12 paymenthod">
                               <%--        <input type="text" value="支付宝">--%>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3">支付码
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6">
                                        <input type="text" id="paycode" name="paycode"
                                               value="${orderProduct.paycode}"

                                              required="required" disabled
                                               class="form-control col-md-7 col-xs-12">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="control-label col-md-3 col-sm-3">支付状态
                                        <span class="required">*</span>
                                    </label>
                                    <div class="col-md-6 col-sm-6">
                                        <c:if test="${orderProduct.issuccess==1}">
                                            <input disabled value="未支付" class="form-control col-md-7 col-xs-12">
                                        </c:if>
                                        <c:if test="${orderProduct.issuccess==0}">
                                            <input disabled value="已支付" class="form-control col-md-7 col-xs-12">
                                        </c:if>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-2 col-sm-2 col-md-offset-3">
                                        <button type="button" id="btnAdd" class="btn btn-primary">提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>

        </div>
        <!-- /page content -->
        <!-- footer content -->
        <%@ include file="/WEB-INF/jsps/footer.jsp" %>
        <!-- /footer content -->
    </div>
</div>

<!-- jQuery -->
<script
        src="${pageContext.request.contextPath }/static/vendors/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap -->
<script
        src="${pageContext.request.contextPath }/static/vendors/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- FastClick -->
<script
        src="${pageContext.request.contextPath }/static/vendors/fastclick/lib/fastclick.js"></script>
<!-- NProgress -->
<script
        src="${pageContext.request.contextPath }/static/vendors/nprogress/nprogress.js"></script>
<!-- Chart.js -->
<!-- bootstrap-progressbar -->
<script
        src="${pageContext.request.contextPath }/static/vendors/bootstrap-progressbar/bootstrap-progressbar.min.js"></script>
<!-- iCheck -->
<script
        src="${pageContext.request.contextPath }/static/vendors/iCheck/icheck.min.js"></script>
<!-- Skycons -->
<script
        src="${pageContext.request.contextPath }/static/vendors/skycons/skycons.js"></script>
<!-- jQuery Smart Wizard -->

<!-- Custom Theme Scripts -->
<script
        src="${pageContext.request.contextPath }/static/build/js/custom.min.js"></script>

<!-- PNotify -->
<script src="${pageContext.request.contextPath }/static/vendors/pnotify/dist/pnotify.js"></script>
<script src="${pageContext.request.contextPath }/static/vendors/pnotify/dist/pnotify.buttons.js"></script>
<script src="${pageContext.request.contextPath }/static/vendors/pnotify/dist/pnotify.nonblock.js"></script>

<input type="hidden" id="hideaddress" value="${orderProduct.addressid}"/>

<script type="text/javascript">
    if(${orderProduct.paymethod==0}){
        $("#paymethod").val("支付宝");

    }
    else if(${orderProduct.paymethod==1})
    {
            $("#paymethod").val("微信");
    }
    else if(${orderProduct.paymethod==2}){
        $("#paymethod").val("银行卡");
    }

    // $("#paymethod").val("支付宝");


    $("#btnAdd").click(function () {

        var oid = $("#oid").val();
        var addressid = $("#addressid").val();

        $.ajax({
            url: '${pageContext.request.contextPath }/order/updateorders',
            data: {"oid": oid, "addressid": addressid},
            dataType: 'json',
            type: 'post',
            success: function (result) {
                if (result.code == 0) {
                    $(location).attr("href", "${pageContext.request.contextPath }/order/orderListView");
                }
                else {
                    alert(result.msg);
                }

            }
        });

    });
</script>
</body>
</html>
